package com.dyz.leetcode._19_greedy;

public class _330_minPatches {
    public int minPatches(int[] nums, int n) {
        int res=0;
        int x = 1;
        int index =0;
        while (x<=n){
            if(index<nums.length && nums[index]<= x){
                x += nums[index];
                index++;
            }else {
                res++;
                x*=2;
            }
        }
    return res;
    }
}
